<?php 

if(!isset($_SESSION['username'])){
		echo "<script>alert('请登录！');window.location.href='index.php?m=admin&c=manage'</script>";die;
	}
	
	//获取得知烂ID 
	$id = $_GET['id'];
	//查找需要修改的分类数据
	$cate_upd = dbselOne($con,'category','*',"$id");


	//修改填入的原始值
	$url = $cate_upd['url'];
	$category_name = $cate_upd['category_name'];

	//判断是否输出改变类选项
	$pid = $cate_upd['pid'];


	if($_POST){
		$field['url'] = htmlspecialchars(trim($_POST['url']));
		$field['category_name'] = htmlspecialchars(trim($_POST['category_name']));
		$field['pid'] = htmlspecialchars(trim($_POST['pid']));
		$query = dbupdate($con,'category',$field,"id=$id");
		if($query){
			echo "<script>alert('修改成功');location.href='index.php?m=admin&c=category'</script>";
		}else{
			echo "<script>alert('修改失败');location.href='index.php?id={$id}&m=admin&c=category&v=cate_upd'</script>";
		}
	}





	assign('url',$url);

	assign('category_name',$category_name);

	assign('pid',$pid	);

	//权限管理
	authonity($con);




?>